package com.roc.web.action.table;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class CompTransSearchCondtion extends BaseSearchCondition {

	
	/**
	 * file
	 * long:serialVersionUID:CompTransSearchCondtion.java
	 */
	
	private static final long serialVersionUID = 1L;
	private String MinDate;
	private String MaxDate;
	private String orgName;
	
	private String companyName;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer  sb = new StringBuffer();
		sb.append(" SELECT COUNT( DISTINCT t.org_name) FROM  apsmgm.t_report_day  t");
		sb.append(" WHERE  t.trans_dt>="+MinDate+" AND t.trans_dt<="+MaxDate+" ");
		if(Constance.isNotEmpty(orgName)){
			sb.append(" AND  t.org_name like '%"+orgName.trim()+ "%' ");
		}
		if(Constance.isNotEmpty(companyName)){
			sb.append(" AND  t.company_name like '%"+companyName.trim()+ "%' ");
		}
		
	
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		StringBuffer  sb = new StringBuffer();
		sb.append(" select t.org_name, SUM(t.trans_amt), SUM(t.trans_count), t.company_name,  COUNT( Distinct t.mcht_cd),sum(t.trans_fee), SUM(t.income) " );
		sb.append("from  apsmgm.t_report_day  t ");
		sb.append(" WHERE  t.trans_dt>="+MinDate+" AND t.trans_dt<="+MaxDate+" ");
		if(Constance.isNotEmpty(orgName)){
			sb.append(" AND  t.org_name like '%"+orgName.trim()+ "%' ");
		}
		if(Constance.isNotEmpty(companyName)){
			sb.append(" AND  t.company_name like  '%"+companyName.trim()+ "%' ");
		}
		sb.append("  GROUP BY t.org_name,t.company_name  ");
				return sb.toString();
	}


	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return "  ORDER BY t.org_name   ";
	}

	public String getMinDate() {
		return MinDate;
	}

	public void setMinDate(String minDate) {
		MinDate = minDate;
	}

	public String getMaxDate() {
		return MaxDate;
	}

	public void setMaxDate(String maxDate) {
		MaxDate = maxDate;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	


	
}
